import os
import logging


# 默认的参数配置
DEFAULT_ENDPOINTS_PATH = "endpoints.yml"
DEFAULT_CREDENTIALS_PATH = "credentials.yml"
DEFAULT_CONFIG_PATH = "config.yml"
DEFAULT_DOMAIN_PATH = "domain.yml"
DEFAULT_ACTIONS_PATH = "actions"
DEFAULT_MODELS_PATH = "models"
DEFAULT_DATA_PATH = "data"
DEFAULT_E2E_TESTS_PATH = "tests"
DEFAULT_RESULTS_PATH = "results"
DEFAULT_NLU_RESULTS_PATH = "nlu_comparison_results"
DEFAULT_NLU_SUBDIRECTORY_NAME = "nlu"  # 子目录中nlu目录
DEFAULT_CORE_SUBDIRECTORY_NAME = "core"  # 子目录中core目录
DEFAULT_REQUEST_TIMEOUT = 60 * 5  # 5 minutes
DEFAULT_RESPONSE_TIMEOUT = 60 * 60  # 1 hour

TEST_DATA_FILE = "test.md"
TRAIN_DATA_FILE = "train.md"
NLG_DATA_FILE = "responses.md"
RESULTS_FILE = "results.json"
NUMBER_OF_TRAINING_STORIES_FILE = "num_stories.json"
PERCENTAGE_KEY = "__percentage__"

# 文件夹名
PACKAGE_NAME = "rasa"

# 架构文件
CONFIG_SCHEMA_FILE = "nlu/schemas/config.yml"   # 配置模式文件
DOMAIN_SCHEMA_FILE = "core/schemas/domain.yml"  # 域模式文件

# 端口设置
DEFAULT_RASA_X_PORT = 5002
DEFAULT_RASA_PORT = 5005

# 文档分模块详情链接
DOCS_BASE_URL = "https://rasa.com/docs/rasa"
DOCS_URL_POLICIES = DOCS_BASE_URL + "/core/policies/"
DOCS_URL_DOMAINS = DOCS_BASE_URL + "/core/domains/"
DOCS_URL_STORIES = DOCS_BASE_URL + "/core/stories/"
DOCS_URL_ACTIONS = DOCS_BASE_URL + "/core/actions/"
DOCS_URL_CONNECTORS = DOCS_BASE_URL + "/user-guide/connectors/"
DOCS_URL_EVENT_BROKERS = DOCS_BASE_URL + "/api/event-brokers/"
DOCS_URL_PIKA_EVENT_BROKER = DOCS_URL_EVENT_BROKERS + "#pika-event-broker"
DOCS_URL_TRACKER_STORES = DOCS_BASE_URL + "/api/tracker-stores/"
DOCS_URL_PIPELINE = DOCS_BASE_URL + "/nlu/choosing-a-pipeline/"
DOCS_URL_COMPONENTS = DOCS_BASE_URL + "/nlu/components/"
DOCS_URL_TRAINING_DATA_NLU = DOCS_BASE_URL + "/nlu/training-data-format/"
DOCS_URL_MIGRATE_GOOGLE = DOCS_BASE_URL + "/migrate-from/google-dialogflow-to-rasa/"
DOCS_URL_MIGRATION_GUIDE = DOCS_BASE_URL + "/migration-guide/"

DOCS_BASE_URL_RASA_X = "https://rasa.com/docs/rasa-x"

LEGACY_DOCS_BASE_URL = "http://legacy-docs.rasa.com"

CONFIG_MANDATORY_KEYS_CORE = ["policies"]
CONFIG_MANDATORY_KEYS_NLU = ["language", "pipeline"]
CONFIG_MANDATORY_KEYS = CONFIG_MANDATORY_KEYS_CORE + CONFIG_MANDATORY_KEYS_NLU

MINIMUM_COMPATIBLE_VERSION = "1.9.0"

GLOBAL_USER_CONFIG_PATH = os.path.expanduser("~/.config/rasa/global.yml")

# 日志级别设置
DEFAULT_LOG_LEVEL = "INFO"   # 默认是INFO
DEFAULT_LOG_LEVEL_RASA_X = "WARNING"  # 默认是WARNING
DEFAULT_LOG_LEVEL_LIBRARIES = "ERROR"  # 默认是ERROR
ENV_LOG_LEVEL = "LOG_LEVEL"
ENV_LOG_LEVEL_LIBRARIES = "LOG_LEVEL_LIBRARIES"

# 自定义的调试日志级别
ENV_LOG_DEBUG = logging.DEBUG

DEFAULT_SANIC_WORKERS = 1
ENV_SANIC_WORKERS = "SANIC_WORKERS"
ENV_SANIC_BACKLOG = "SANIC_BACKLOG"

DEFAULT_SESSION_EXPIRATION_TIME_IN_MINUTES = 60
DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION = True   # 默认插槽结转至新会话

ENV_GPU_CONFIG = "TF_GPU_MEMORY_ALLOC"
ENV_CPU_INTER_OP_CONFIG = "TF_INTER_OP_PARALLELISM_THREADS"
ENV_CPU_INTRA_OP_CONFIG = "TF_INTRA_OP_PARALLELISM_THREADS"


# ---------------自定义常量-------------------------

# 临时文件目录设置
TMP_DIR = "/Users/lilong/Desktop/rasa_dev_release/rasa_bot_426_tiny/bot_playground/tmp_dir"